package com.joplus.housekeeper.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.joplus.housekeeper.R;
import com.joplus.housekeeper.bean.RecommandListBean;
import com.joplus.housekeeper.utils.CommonAdapter;
import com.joplus.housekeeper.utils.StringUtils;
import com.joplus.housekeeper.utils.ViewHolder;
import com.nostra13.universalimageloader.core.ImageLoader;

import java.util.List;

/**
 *
 *
 * Created by tangdehao on 16/4/26.
 */
public class RecommandListAdapter extends CommonAdapter<RecommandListBean.ListBean>{



    /**
     * @param context  上下文
     * @param layoutId 布局id
     * @param datas    数据
     */
    public RecommandListAdapter(Context context, int layoutId, List<RecommandListBean.ListBean>datas) {
        super(context, layoutId, datas);

    }

    @Override
    public void convert(ViewHolder holder, final RecommandListBean.ListBean listBean) {
        ImageView ivRestLogo= (ImageView) holder.getConvertView().findViewById(R.id.iv_rest_logo);
//        ImageView ivRestType=(ImageView) holder.getConvertView().findViewById(R.id.iv_restType);
//        ImageView tvRestLevel=(ImageView) holder.getConvertView().findViewById(R.id.tv_rest_level);;;

        TextView tvRestName=(TextView) holder.getConvertView().findViewById(R.id.tv_rest_name);
        TextView tvOneSentence=(TextView) holder.getConvertView().findViewById(R.id.tv_oneSentence);
        TextView tvAvgPrice=(TextView) holder.getConvertView().findViewById(R.id.tv_avgPrice);
        TextView tvCuisineId=(TextView) holder.getConvertView().findViewById(R.id.tv_cuisineId);
        TextView tvHotArea=(TextView) holder.getConvertView().findViewById(R.id.tv_hotArea);
       // TextView tvConditionMoney=(TextView) holder.getConvertView().findViewById(R.id.tv_conditionMoney);

        ImageLoader.getInstance().displayImage(listBean.getPicUrl(),ivRestLogo);
        StringUtils.setText(tvOneSentence, listBean.getTitle());
        //直接去除名称布
        tvRestName.setVisibility(View.GONE);
        String[] lable=listBean.getLabels().split("@@");
        StringUtils.setText(tvAvgPrice,lable[0]);
        StringUtils.setText(tvCuisineId,lable[1]);
        tvHotArea.setVisibility(View.GONE);
//        StringUtils.setText(tvOneSentence,);

        LinearLayout layout=(LinearLayout) holder.getConvertView().findViewById(R.id.layout_shop_list);
        layout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               /* Intent intent=new Intent(context,WebViewActivity.class);
                intent.putExtra(WebViewActivity.LINKURL,listBean.getContentUrl());
                intent.putExtra("restType",0);

                context.startActivity(intent);*/

            }
        });
    }





}
